import axios from '@/apis'

/**
 * 加入购物车
 * @param {object} data
 * {
 *   skuId: string
 *   count: integer - 商品数量
 * }
 */
export const joinCartAPI = data => axios.post('/member/cart', data)

/**
 * 删除购物车中的商品
 * @param {Array} data - skuId的集合
 * [id1, id2, id3...]
 */
export const removeCartAPI = ids =>
  axios.delete('/member/cart', {
    data: { ids },
  })

// 获取购物车列表
export const getCartListAPI = () => axios('/member/cart')

// 合并购物车
/* 
  data [
    {
      skuId - 商品skuId
      selected - 商品选中状态
      count - 商品数量
    },
    {...}
  ]
*/
export const mergeCartAPI = data => axios.post('/member/cart/merge', data)
